package com.xcc.wchatrobot;

import java.util.List;

public class RetTuLin {
    private static final String TEXT = "text";

    public boolean isOk() {
        if (intent == null) return false;
        return intent.code < 20000;
    }

    public String getText() {
        if (results == null) return null;
        for (int i = 0; i < results.size(); i++) {
            ResultsBean resultsBean = results.get(0);
            if (TEXT.equals(resultsBean.resultType)) {
                return resultsBean.getText();
            }
        }
        return null;
    }

    /**
     * intent : {"code":10005,"intentName":"","actionName":"","parameters":{"nearby_place":"酒店"}}
     * results : [{"groupType":1,"resultType":"url","values":{"url":"http://m.elong.com/hotel/0101/nlist/#indate=2016-12-10&outdate=2016-12-11&keywords=%E4%BF%A1%E6%81%AF%E8%B7%AF"}},{"groupType":1,"resultType":"text","values":{"text":"亲，已帮你找到相关酒店信息"}}]
     */
    public IntentBean intent;
    public List<ResultsBean> results;

    public static class IntentBean {
        /**
         * code : 10005
         * intentName :
         * actionName :
         * parameters : {"nearby_place":"酒店"}
         */
        public int code;
    }

    public static class ResultsBean {
        public String resultType;
        public ValuesBean values;

        public String getText() {
            if (values == null) return null;
            return values.text;
        }
    }

    public static class ValuesBean {
        public String text;
    }
}
